﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//用“埃氏筛法”求2-100以内的素数
namespace ConsoleApp_b3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            int[] nums = new int[101];
            for(int i = 0; i <= 100; i++)
            {
                nums[i] = 1;//非素数用0表示
            }
            Console.WriteLine("  2--100的素数");
            for(int i = 2; i <=10; i++)
            {
                for(int j = 2*i; j <=100; j+=i)
                {
                    nums[j] = 0;
                }
            }
            for(int i = 2; i <= 100; i++)
            {
                if (nums[i] == 1)
                {
                    Console.Write(" "+i);
                    n++;
                    if (n < 10) 
                        continue;
                    Console.WriteLine();
                    n = 0;
                }
            }
            Console.Read();
        }
    }
}
